﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OutdoorLib.BaseEntity.Infrastructure;
using Grishko.DataTier;
using OutdoorLib.BaseEntity.Filters;
using Ecopsy.Tools;

public partial class Ctl_ctlSideListSelector : System.Web.UI.UserControl
{
    private const string filterSourceKey="filterSourceKey";
    private ConstractionSheduleFilter filterSource = null;

    protected void Page_Load(object sender, EventArgs e)
    {
        MyInit ();
        
    }
    private void MyInit()
    {
        ctlFilterEditor1.DataSource = GetFilterSource;

    }

    private Filter FilterSource
    { get 
        {
            if (CacheTools.IsSessionCacheObject(filterSourceKey))
                filterSource = (ConstractionSheduleFilter)CacheTools.GetSessionCacheObect(filterSourceKey);
            else
            {
                filterSource = new ConstractionSheduleFilter();
                filterSource.dtStart = dtStart;
                filterSource.dtFinish = dtFinish;
            }
            
            return filterSource;
        }
    }

    private DateTime dtStart {get {return  DateTimeTools.GetDate(txtDtStart.Text, DateTimeTools.GetFisrtDayInMonth(DateTime.Now)); } }
    private DateTime dtFinish { get { return DateTimeTools.GetDate(txtDtFinish .Text, DateTimeTools.GetFisrtDayInMonth(DateTime.Now)); } }


    private Filter GetFilterSource()
    {
        return FilterSource;
    }

}
